<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改邊角料信息')" />
	<th:block th:include="include :: select2-css" />
</head>
<body>
    <div class="main-content">
        <form class="form-horizontal" id="form-leftoverIn-edit" th:object="${leftoverIn}">
            <input name="tableId"  type="hidden"  th:field="*{tableId}" />
            <h4 class="form-header h4">基本信息</h4>
            <div class="row">
            	<div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">入庫單號：</label>
                        <div class="col-sm-8">
                            <input name="inId" placeholder="請輸入入庫單號" class="form-control" type="text" th:field="*{inId}" readonly>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">入庫人：</label>
                        <div class="col-sm-8">
                            <input name="manage" placeholder="請輸入入庫人" class="form-control" type="text" maxlength="30" th:field="*{manage}" required>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">接收人：</label>
                        <div class="col-sm-8">
                            <input name="receive" placeholder="請輸入接收人" class="form-control" type="text" maxlength="30" th:field="*{receive}" required>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">時間：</label>
                        <div class="col-sm-8">
                            <th:input name="time" placeholder="請輸入時間" class="form-control" type="text" maxlength="30" th:text="${#dates.format(leftoverIn.time, 'yyyy-MM-dd')}" disabled />
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">邊角料料號：</label>
                        <div class="col-sm-8">
                            <input name="leftoverId" placeholder="請輸入邊角料料號" class="form-control" type="text" maxlength="30" th:field="*{leftoverId}" readonly>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">樓層：</label>
                        <div class="col-sm-8">
                            <input name="floor" placeholder="請輸入樓層" class="form-control" type="text" maxlength="30" th:field="*{floor}" required>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">入庫數量：</label>
                        <div class="col-sm-8">
                            <input name="inNum" placeholder="請輸入入庫數量" class="form-control" type="text" maxlength="30" th:field="*{inNum}" required>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">脫脂脫水比例：</label>
                        <div class="col-sm-8">
                            <input name="proportion" placeholder="請輸入脫脂脫水比例" class="form-control" type="text" maxlength="30" th:field="*{proportion}" required>
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">單位：</label>
                        <div class="col-sm-8">
                            <select name="unit" class="form-control m-b" th:with="type=${@dict.getType('sys_leftover_unit')}">
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{unit}"></option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">狀態：</label>
                        <div class="col-sm-8">
                            <label class="toggle-switch switch-solid">
                                <input type="checkbox" id="state" th:checked="${leftoverIn.state == '0' ? true : false}" disabled>
                                <span></span>
                            </label>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <div class="row">
        <div class="col-sm-offset-5 col-sm-10">
            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: select2-js" />
	<script type="text/javascript">
        var prefix = ctx + "system/leftoverIn";
        function submitHandler() {
	        if ($.validate.form()) {
	        	var data = $("#form-leftoverIn-edit").serializeArray();
	        	var state = $("input[id='state']").is(':checked') == true ? 0 : 1;
	        	// var roleIds = $.form.selectCheckeds("role");
	        	// var postIds = $.form.selectSelects("post");
	        	data.push({"name": "state", "value": state});
	        	// data.push({"name": "roleIds", "value": roleIds});
	        	// data.push({"name": "postIds", "value": postIds});
	        	$.operate.saveTab(prefix + "/edit", data);
	        }
	    }

        /* 用户管理-修改-选择部门树 */
        function selectDeptTree() {
        	var deptId = $.common.isEmpty($("#treeId").val()) ? "100" : $("#treeId").val();
            var url = ctx + "system/dept/selectDeptTree/" + deptId;
		    var options = {
				title: '选择部门',
				width: "380",
				url: url,
				callBack: doSubmit
			};
			$.modal.openOptions(options);
		}

		function doSubmit(index, layero){
			var tree = layero.find("iframe")[0].contentWindow.$._tree;
			var body = $.modal.getChildFrame(index);
   			$("#treeId").val(body.find('#treeId').val());
   			$("#treeName").val(body.find('#treeName').val());
   			$.modal.close(index);
		}

		$(function() {
            $('#post').select2({
                placeholder: "请选择岗位",
                allowClear: true
            });
        })
    </script>
</body>
</html>